<template>
  <div>
    <el-dialog
      title="住宿信息"
      :visible.sync="dialogVisible"
      width="600px"
      destroy-on-close
    >
      <div>
        <el-row v-for="(item, index) in dormList" :key="index">
          <h2>{{ item.ctime }}</h2>
          <h2>{{ item.room.address }} - {{ item.room.name }}</h2>
        </el-row>
        <el-row v-for="(item, indx) in dormHisList" :key="indx">
          <el-tag>{{ item.ctime }} - {{ item.outtime }}</el-tag>
          <h2>{{ item.room.address }} - {{ item.room.name }}</h2>
        </el-row>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { studentService } from "@/api/dormService";

export default {
  dicts: [],
  components: {},

  data() {
    return {
      resolve: null,
      dialogVisible: false,
      dormList: [],
      dormHisList: [],

      cateOptions: [],

      // 表单参数
      studentId: "",
    };
  },
  created() {},
  methods: {
    open(row) {
      // console.log(row);
      this.dialogVisible = true;

      this.studentId = row.id;
      this.getDormList();
      return new Promise((resolve) => {
        this.resolve = resolve;
      });
    },

    getDormList() {
      if (!this.studentId) {
        return false;
      }

      studentService.getDormList({ studentId: this.studentId }).then((response) => {
        console.log(response);

        this.dormHisList = response.data.dormHisList;
        this.dormList = response.data.dormList;
        // this.cateOptions = response.data;
      });
    },

    // 取消按钮
    cancel() {
      this.dialogVisible = false;
      // this.reset();
    },
  },
};
</script>

<style lang="scss" scoped></style>
